﻿namespace HRM.CORE.CLASS
{
    using System; using Extra.ERP;
    using System.Data;
    using System.Windows.Forms; using Common;

    public class clsSalaryOption
    {
        private bool m_IsAllowanceReCreate;

        public clsSalaryOption()
        {
            try
            {
                this.m_IsAllowanceReCreate = bool.Parse(CheckOption("IsAllowanceReCreate"));
            }
            catch
            {
                this.m_IsAllowanceReCreate = false;
            }
        }

        public static string CheckOption(string FieldName)
        {
            try
            {
                DataSet set = new DataSet();
                set.ReadXml(Application.StartupPath + @"\Layout\salaryOption.xml");
                return set.Tables[0].Rows[0][FieldName].ToString();
            }
            catch
            {
                return "";
            }
        }

        public void SaveOption()
        {
            DataSet set = new DataSet();
            using (DataTable table = new DataTable())
            {
                table.Columns.Add("IsAllowanceReCreate", typeof(string));
                object[] objArray = new object[] { this.m_IsAllowanceReCreate.ToString() };
                table.Rows.Add(new object[0]);
                table.Rows[0][0] = objArray[0];
                set.Tables.Add(table);
            }
            try
            {
                set.WriteXml(Application.StartupPath + @"\Layout\salaryOption.xml");
            }
            catch
            {
            }
        }

        public static void SaveOption(bool IsAllowanceReCreate)
        {
            DataSet set = new DataSet();
            using (DataTable table = new DataTable())
            {
                table.Columns.Add("IsAllowanceReCreate", typeof(string));
                object[] objArray = new object[] { IsAllowanceReCreate.ToString() };
                table.Rows.Add(new object[0]);
                table.Rows[0][0] = objArray[0];
                set.Tables.Add(table);
            }
            try
            {
                set.WriteXml(Application.StartupPath + @"\Layout\salaryOption.xml");
            }
            catch
            {
            }
        }

        public bool IsAllowanceReCreate
        {
            get
            {
                return this.m_IsAllowanceReCreate;
            }
            set
            {
                this.m_IsAllowanceReCreate = value;
            }
        }
    }
}

